<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                xmlns:security="http://www.springframework.org/security/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">邀请明细统计</ui:define>
    <ui:define name="content">

        <h:form>
            <p:defaultCommand target="search"/>
            <div class="topbar clearfix" style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="left">
                        <p:commandButton id="toggler" type="button" value="展示选择"
                                         style="width: auto;"
                                         icon="ui-icon-calculator"/>
                        <p:columnToggler datasource="distributionRecordDataTable" trigger="toggler"/>
                    </f:facet>
                    <f:facet name="right">
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         rendered="#{distributionRecordBean.isNormal()}"
                                         update="@form"/>
                        <p:commandButton value="重置" icon="fa fa-refresh"
                                         rendered="#{distributionRecordBean.isNormal()}"
                                         actionListener="#{distributionRecordBean.onReset}"
                                         process="@this" update="@form"/>
                        <p:commandButton value="导出" icon="fa fa-download" ajax="false">
                            <p:dataExporter type="xls" target="distributionRecordDataTable" fileName="activityParticipateStatistic"/>
                        </p:commandButton>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">
                        <div class="card">
                            <h1>查询条件</h1>
                            <p:panelGrid columns="8" layout="grid"
                                         columnClasses="ui-grid-col-1,ui-grid-col-2"
                                         styleClass="ui-panelgrid-blank"
                                         style="border:0px none; background-color:transparent;text-align:center;">
                                <p:outputLabel for="distributionActivityId" value="分销活动"/>
                                <p:selectOneMenu id="distributionActivityId" value="#{distributionRecordBean.$.distributionActivityId}">
                                    <f:selectItem itemLabel="请选择" itemValue="" noSelectionOption="true"/>
                                    <f:selectItems value="#{distributionRecordBean.distributionActivityList}"/>
                                </p:selectOneMenu>

                                <p:outputLabel for="startTime" value="开始时间"/>
                                <p:calendar id="startTime" value="#{distributionRecordBean.$.startTime}"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATETIME_FORMAT')}"/>

                                <p:outputLabel for="endTime" value="结束时间"/>
                                <p:calendar id="endTime" value="#{distributionRecordBean.$.endTime}"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATETIME_FORMAT')}"/>

                                <p:outputLabel for="selectProduct" value="产品"/>
                                <p:selectCheckboxMenu id="selectProduct" value="#{distributionRecordBean.$.productIds}"
                                                      updateLabel="true" multiple="true" filter="true">
                                    <f:selectItems value="#{distributionRecordBean.productList}" />
                                </p:selectCheckboxMenu>

                                <p:outputLabel for="selectChannel" value="渠道"/>
                                <p:selectCheckboxMenu id="selectChannel" value="#{distributionRecordBean.$.channelIds}"
                                                      updateLabel="true" multiple="true" filter="true">
                                    <f:selectItems value="#{distributionRecordBean.channelList}" />
                                </p:selectCheckboxMenu>

                                <p:outputLabel for="selectPlatform" value="平台"/>
                                <p:selectCheckboxMenu id="selectPlatform" value="#{distributionRecordBean.$.platforms}"
                                                      updateLabel="true" multiple="true" filter="true">
                                    <f:selectItems value="#{distributionRecordBean.platformList}" />
                                </p:selectCheckboxMenu>

                                <p:outputLabel for="superiorPhoneNumber" value="上家用户手机号"/>
                                <p:inputText id="superiorPhoneNumber" value="#{distributionRecordBean.$.superiorPhoneNumber}"/>

                                <p:outputLabel for="subordinatePhoneNumber" value="下家用户手机号"/>
                                <p:inputText id="subordinatePhoneNumber" value="#{distributionRecordBean.$.subordinatePhoneNumber}"/>
                            </p:panelGrid>
                        </div>
                        <div class="card">
                            <p:dataTable id="distributionRecordDataTable"
                                         style="width: 100%;text-align:center"
                                         var="record"
                                         value="#{distributionRecordBean.lazyDataModel}"
                                         rows="#{constants:get('ROWS')}"
                                         lazy="true"
                                         paginator="true"
                                         paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                         rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                         scrollable="true"
                                         reflow="true"
                                         selection="#{distributionRecordBean.selectedRecords}"
                                         resizableColumns="true">
                                <p:column headerText="支付时间">
                                    <h:outputText value="#{record.createTime}"/>
                                </p:column>

                                <p:column headerText="佣金提成" style="text-align:center;">
                                    <h:outputText value="#{record.commission}"/>
                                </p:column>
                                <p:column headerText="订单ID" style="text-align:center;">
                                    <h:outputText value="#{record.orderId}"/>
                                </p:column>
                                <p:column headerText="分享邀请类型" style="text-align:center;">
                                    <h:outputText value="#{record.shareType}"/>
                                </p:column>
                                <p:column headerText="上家手机号" style="text-align:center;">
                                    <h:outputText value="#{record.superiorPhoneNumber}"/>
                                </p:column>
                                <p:column headerText="下家手机号" style="text-align:center;">
                                    <h:outputText value="#{record.subordinatePhoneNumber}"/>
                                </p:column>
                                <p:column headerText="产品" style="text-align:center;">
                                    <h:outputText value="#{record.product}"/>
                                </p:column>
                                <p:column headerText="渠道" style="text-align:center;">
                                    <h:outputText value="#{record.channel}"/>
                                </p:column>
                                <p:column headerText="平台" style="text-align:center;">
                                    <h:outputText value="#{record.platform}"/>
                                </p:column>
                            </p:dataTable>
                        </div>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>